﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;
using WXYW.DAL;
using WXYW.Controls;
using System.Collections;

namespace WXYW
{
    public partial class ReturnToFactoryCheckList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindForm();
            }
        }

        private void BindForm()
        {
            ReturnToFactoryService service = new ReturnToFactoryService();
            WaitCheckGridView.DataSource = service.GetReturnToFactoryFormByStatus("返厂-待验证", ContextService.CurrentAccount);
            WaitCheckGridView.DataBind();
        }

        protected void rtfLinkButton_Click(object sender, EventArgs e)
        {
            string returnToFactoryID = ((LinkButton)sender).CommandArgument;

            Response.Redirect(string.Format("ReturnToFactoryCheckForm.aspx?{0}={1}", Constants.QUERYSTR_RETURNTOFACTORY_ID, returnToFactoryID));
        }

        protected void WaitCheckGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            if (e.NewPageIndex >= 0 && e.NewPageIndex < WaitCheckGridView.PageCount)
            {
                WaitCheckGridView.PageIndex = e.NewPageIndex;
            }
            
            BindForm();
        }

        protected void WaitCheckGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.DataItem != null)
            {
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#FFFF99'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                ((Label)e.Row.FindControl("IDLbl")).Text = (e.Row.RowIndex + 1).ToString();
            }
        }

        protected IEnumerable GridView_MustAddARow(IEnumerable data)
        {
            List<ReturnToFactoryForm> dds = (List<ReturnToFactoryForm>)data;
            dds.Add(new ReturnToFactoryForm());
            return dds;
        }
    }
}
